# 668 困难：乘法表中第k小的数

def findKthNumber(m, n, k):
    # 超时
    # l = []
    # for i in range(1, m + 1):
    #     for j in range(1, n + 1):
    #         l.append(i * j)
    # l = sorted(l)
    # return l[k - 1]

    # 二分查找 每行递增，求每行小于k的数目之和
    l = 1
    r = m * n
    while l < r:
        mid = (r - l) // 2 + l
        cnt = mid // n * n
        for i in range(mid // n + 1, m + 1):
            cnt += mid // i
        if cnt >= k:
            r = mid
        else:
            l = mid + 1

    return l
